#ifndef Arrayok
#define Arrayok

template <class TYPE>
class Array{
	public:
		Array(int size = 1){
			capacity = size;
			elements = new TYPE [capacity];
		};
		Array(const Array<TYPE> & arr);
		~Array();
		inline TYPE & operator [ ](int index);
		inline Array<TYPE> & operator =(const Array<TYPE> & rarr);
		void changesize(int newsize);
		inline int length() const;
	private:
		TYPE *elements;
		int capacity;
		inline void deepCopy(const Array<TYPE> & arr);
};
// template <class TYPE>
// Array<TYPE>::Array(int size){
// capacity = size;
// elements = new TYPE [capacity];
// }
template <class TYPE>
inline TYPE & Array<TYPE>::operator[](int index)
{
return elements[index];
}
template <class TYPE>
void Array<TYPE>::changesize(int newsize)
{
	TYPE *newelements = new TYPE [newsize];
	int limit = (newsize > capacity)?capacity:newsize;
	for(int i=0;i<limit;i++){
		newelements[i] = elements[i];
	}
	delete [] elements;
	elements = newelements;
	capacity = newsize;
}
template <class TYPE>
inline int Array<TYPE>::length() const
{
	return capacity;
}
template <class TYPE>
Array<TYPE>::~Array()
{
	delete [] elements;
}
template <class TYPE>
Array<TYPE>::Array(const Array<TYPE> & arr)
{
	deepCopy(arr);
}
template <class TYPE>
inline void Array<TYPE>::deepCopy(const Array<TYPE> & arr)
{
	capacity = arr.capacity;
	elements = new TYPE [capacity];
	for (int i = 0;i<capacity;i++)
	{
		elements[i] = arr.elements[i];
	}
}
template <class TYPE>
inline Array<TYPE> & Array<TYPE>::operator=(const Array<TYPE>& rarr)
{
	if(this == &rarr){
		return *this;
	}
	delete [] elements;
	deepCopy(rarr);
	return *this;
}

#endif